import request from "@/utils/request";

/**
 * 获取节点下任务列表
 * @param {*} query
 */
export function selectDeptTaskByNodeId(query) {
    return request({
        url: `/hd/saveTask/selectDeptTaskByNodeId/${query.handleId}/${query.nodeId}`,
        method: "get",
    });
}

/**
 * 添加新任务
 */
export function addDeptTask(data) {
    return request({
        url: "/hd/saveTask",
        method: "post",
        data: data,
    });
}

/**
 * 编辑任务
 * @param {*} data
 * @returns
 */
export function editDeptTask(data) {
    return request({
        url: "/hd/saveTask",
        method: "put",
        data: data,
    });
}

/**
 * 开启二级任务
 * @param {*} parentId
 * @returns
 */
export function openSecondTasks(parentId) {
    return request({
        url: `/hd/saveTask/openSecondTasks/${parentId}`,
        method: "put",
    });
}

/**
 * 提交任务
 * @param {*} taskId
 * @param {*} submitContent
 * @returns
 */
export function submitTask(taskId, submitContent) {
    return request({
        url: `/hd/saveTask/submitTask/${taskId}`,
        method: "put",
        data: submitContent,
    });
}

/**
 * 一级任务提交接口
 * @param {*} taskId
 * @returns
 */
export function completeTask(taskId) {
    return request({
        url: "/hd/saveTask/completeTask/" + taskId,
        method: "put",
    });
}

/**
 * 设置任务时限
 * @param {*} taskId
 * @param {*} timeLimit
 * @returns
 */
export function setTaskTimeLimit(taskId, timeLimit) {
    return request({
        url: `/hd/saveTask/setDDL/${taskId}`,
        method: "put",
        data: {
            ddl: timeLimit,
        },
    });
}

/**
 * 获取任务详情
 * @param {*} taskId
 * @returns
 */
export function getTaskDetail(taskId) {
    return request({
        url: `/hd/saveTask/${taskId}`,
        method: "get",
    });
}
